package com.ytjj.qmyx.admin.service.impl;

import com.ytjj.qmyx.admin.dao.PlatformStatisticsDao;
import com.ytjj.qmyx.admin.model.request.PlatfromStatisticsRequest;
import com.ytjj.qmyx.admin.service.PlatformStatisticsService;
import com.ytjj.qmyx.mall.model.PlatformStatistics;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * 
 * 
 * @Version 1.0
 **/
@Service
public class PlatformStatisticsServiceImpl implements PlatformStatisticsService {

    @Autowired
    private PlatformStatisticsDao platformStatisticsDao;

    @Override
    public List<PlatformStatistics> getPlatList(PlatfromStatisticsRequest platfromStatisticsRequest) {
        String sTime = platfromStatisticsRequest.getDayTime() + " 00:00:00";
        String eTime = platfromStatisticsRequest.getDayTime() + " 23:59:59";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date startTime = sdf.parse(sTime);
            Date endTime = sdf.parse(eTime);
            platfromStatisticsRequest.setStartTime(startTime);
            platfromStatisticsRequest.setEndTime(endTime);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return platformStatisticsDao.getPlatList(platfromStatisticsRequest);
    }
}
